import Vue from 'vue'
import App from './App'
import router from './router'
import axios from './api/index';
import imageView from '@/assets/js/preview.js';
import { Pagination, Message, Loading, Input, Radio, RadioGroup, Select, Option, Checkbox, CheckboxGroup, Tooltip, MessageBox  } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'babel-polyfill'

Vue.config.productionTip = false

// rem适配
const setHtmlFontSize = () => {
    const htmlDom = document.getElementsByTagName('html')[0];
    let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
    if (htmlWidth >= 1920) {
        htmlWidth = 1920;
    }
    if (htmlWidth <= 1366) {
        htmlWidth = 1366;
    }
    htmlDom.style.fontSize = `${htmlWidth / 1920}px`;
};
window.onresize = setHtmlFontSize;
setHtmlFontSize();

Vue.use(Pagination);
Vue.use(Input);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Select);
Vue.use(Option);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Tooltip);
Vue.use(Loading.directive);
Vue.component(Message.name, Message);
Vue.prototype.axios = axios;
Vue.prototype.$loading = Loading.service;
Vue.prototype.$message = Message;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$imageView = imageView

new Vue({
    el: '#app',
    router,
    components: {
        App
    },
    template: '<App/>'
})
